import { queryList, queryLogList, queryInfo, queryLogInfo, saveJob, updateJob, deleteJob, runJob, pauseJob, resumeJob } from '@/api/job'

const state = {}

const mutations = {}

const actions = {
    queryList({ commit }, params) {
        return new Promise(resolve => {
            queryList(params).then(response => {
                resolve(response.data)
            });
        })
    },
    queryLogList({ commit }, params) {
        return new Promise(resolve => {
            queryLogList(params).then(response => {
                resolve(response.data)
            });
        })
    },
    queryInfo({ commit }, id) {
        return queryInfo(id);
    },
    queryLogInfo({ commit }, id) {
        return queryLogInfo(id);
    },
    saveJob({ commit }, data) {
        return saveJob(data);
    },
    updateJob({ commit }, data) {
        return updateJob(data);
    },
    deleteJob({ commit }, data) {
        return deleteJob(data);
    },
    runJob({ commit }, data) {
        return runJob(data);
    },
    pauseJob({ commit }, data) {
        return pauseJob(data);
    },
    resumeJob({ commit }, data) {
        return resumeJob(data);
    }
}

export default {
    namespaced: true,
    state,
    mutations,
    actions
}
